import { inject } from "vue";

export const TOAST_PROVIDED_KEY = "component:toast";

export const defaultOptions: Readonly<Partial<ToastOptions>> = {
    type: "info",
    duration: 1200
}

export function useToast(): ToastApiInjection {
    return inject(TOAST_PROVIDED_KEY) as ToastApiInjection
}

export interface ToastOptions {
    type?: "info"
    content: string,
    duration?: number
}

export interface ToastApiInjection {
    info: (message: string, options?: ToastOptions) => void,
    show: (options: ToastOptions) => void
}